package com.shanglida.base;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

/**
 * @author maus
 * @deprecated 本地用户登录 以及注册 事件
 * @date 2014-02-26 AM
 */
public class UserService {
	private DaseHelper dbHelper;

	public UserService(Context context) {
		dbHelper = new DaseHelper(context);
	}

	// 登陆事件
	public boolean login(String username, String password) {
		SQLiteDatabase sdb = dbHelper.getReadableDatabase();
		String sql = "select * from user where username=? and password=?";
		Cursor cursor = sdb.rawQuery(sql, new String[] { username, password });
		if (cursor.moveToFirst() == true) {
			cursor.close();
			return true;
		}
		return false;
	}

	// 注册事件

	public boolean register(UserData user) {
		SQLiteDatabase sdb = dbHelper.getReadableDatabase();
		String sql = "insert into user(username,numbile,password,paesword) values(?,?,?,?)";
		Object obj[] = { user.getUsername(), user.getNumbile(),
				user.getPassword(), user.getPaesword() };
		sdb.execSQL(sql, obj);
		return true;

	}
}
